import 'package:flutter/material.dart';
import 'package:flutter_bsbdj/pagers/music/music_channel_man_detail.dart';
import 'package:flutter_bsbdj/utils/toast.dart';

class MusicSearch extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return SearchWidget();
  }
}

class SearchWidget extends State<MusicSearch> {
  TextEditingController _editingController = TextEditingController();

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      appBar: AppBar(
        title: Text("输入歌曲名或者歌手名搜索"),
      ),
      body: Container(
        child: Container(
          margin: EdgeInsets.all(5),
          width: MediaQuery.of(context).size.width,
          height: 50,
          child: Row(
            children: <Widget>[
              Expanded(
                child: TextField(
                  controller: _editingController,
                  decoration: InputDecoration(
                      labelText: "请输入歌曲名或者歌手名",
                      hintText: "请输入歌曲名或者歌手名",
                      border: OutlineInputBorder(
                          borderSide:
                              BorderSide(color: Colors.blueAccent, width: 2)),
                      contentPadding:
                          EdgeInsets.symmetric(vertical: 10, horizontal: 5)),
                ),
              ),
              Container(
                alignment: Alignment.center,
                color: Colors.white,
                width: 60,
                margin: EdgeInsets.only(left: 5),
                child: RaisedButton(
                  child: Text(
                    "搜索",
                    style: TextStyle(color: Colors.blueAccent),
                  ),
                  disabledColor: Color(0x00000000),
                  shape: RoundedRectangleBorder(
                      borderRadius: BorderRadius.all(Radius.circular(5)),
                      side: BorderSide(color: Colors.blueAccent, width: 1)),
                  onPressed: () {
                    String t = _editingController.text;
                    if (t.isEmpty || t == "") {
                      Toast.toast(context, "请输入歌曲名或者歌手名");
                    } else {
                      Navigator.of(context).push(MaterialPageRoute(
                          builder: (context) => ChannelManDetail(
                              _editingController.text,
                              _editingController.text)));
                    }
                  },
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
